<%
var headContent = {
include("/pages/template/head.html"){}
%>

<script type="text/javascript">
    var oper;
    jQuery(function($) {
        // 页面方法
        oper = {
            width : 450,
            height : 500,
            form : document.form1,
            list : function() {
                var url = 'system/user/list';
                this.form.action = url;
                this.form.submit();
            },
            view : function(id) {
                var url = 'system/user/view/'+id;
                var title = '查看用户';
                Iframe(url, this.width, this.height, title, false, false, false, EmptyFunc);
            },
            add : function() {
                var url = 'system/user/add';
                var title = '添加用户';
                Iframe(url, this.width, this.height, title);
            },
            edit : function(id) {
                var url = 'system/user/edit/'+id;
                var title = '修改用户';
                Iframe(url, this.width, this.height, title);
            },
            del : function(id) {
                var url = 'system/user/delete/'+id;
                var title = '确认要删除该用户信息？';
                Confirm(title, function() {
                    form1.action = url;
                    form1.submit();
                });
            }
            ,auth : function(id) {
                var url = 'system/user/auth/'+id;
                var title = '授权角色';
                Iframe(url, 320, 400, title);
            }
        };
        //显示Menu索引
        showMenu('page_system');
        showMenu('page_user');
    });

    //分页
    var paginator = function(page) {
        oper.list();
    };

</script>

<%
};

var bodyContent = {
%>
<form name="form1" action="" method="post"  class="form-inline" role="form">
	<!-- 菜单 -->
	<% include("/pages/template/menu.html"){} %>

	<div class="tableSearch">
		<%  //查询列表 %>
		<div class="form-group">
			<input class="form-control" type="text" name="attr.username" value="${attr.username!''}"
				   placeholder="请输入登陆名" required='required' />
		</div>
		<div class="form-group">
			<input class="form-control" type="text" name="attr.realname" value="${attr.realname!''}"
				   placeholder="请输入真实姓名"  />
		</div>
		<div class="form-group">
			<select name="attr.usertype" class="form-control" >
				<option value="-1">--请选择--</option>
				<option value="1" ${attr.usertype==1?"selected":"" }>管理员</option>
				<option value="2" ${attr.usertype==2?"selected":"" }>普通用户</option>
				<option value="5" ${attr.usertype==5?"selected":"" }>API用户</option>
                <option value="3" ${attr.usertype==3?"selected":"" }>前台用户</option>
                <option value="4" ${attr.usertype==4?"selected":"" }>第三方用户</option>
                <option value="9" ${attr.usertype==9?"selected":"" }>其他用户</option>
			</select>


		</div>
		<div class="form-group">
			<select name="attr.departid" class="form-control"   >
				<option value="-1" >--请选择部门--</option>
				${departSelect}
			</select>
		</div>


		<button type="button" class="btn btn-default" onclick="oper.list();" name="search">
			<span class="glyphicon glyphicon-search"></span> 查 询
		</button>
		<button type="button" class="btn btn-default" onclick="resetForm();">
			<span class="glyphicon glyphicon-refresh"></span> 重 置
		</button>
		<button type="button" class="btn btn-default" onclick="oper.add();">
			<span class="glyphicon glyphicon-plus"></span> 新 增
		</button>
	</div>

	<!-- 数据列表 -->
	<table class="table table-striped table-bordered table-hover">
		<thead>
		<tr>
			<th>序号</th>
			<%  // 列表头部 %>
			<th name="departid" class="sorting">部门</th>
			<th name="username" class="sorting">登陆名</th>
			<th name="realname" class="sorting">真实姓名</th>
			<th name="usertype" class="sorting">类型</th>
			<th name="email" class="sorting">Email</th>
			<th name="tel" class="sorting">手机号</th>
			<th name="create_time" class="sorting">创建时间</th>
			<th>操作</th>
		</tr>
		</thead>
		<tbody>
		<% for(item in page.list){ %>
		<tr>
			<td>${itemLP.index }</td>
			<%  // 列表内容 %>
			<td>${item.departname}</td>
			<td>${item.username}</td>
			<td>${item.realname}</td>
			<td>
				<% if(item.usertype==1) { %>
				管理员
				<%	} %>
				<% if(item.usertype==2) { %>
				普通用户
				<%	} %>
				<% if(item.usertype==3) { %>
				前台用户
				<%	} %>
				<% if(item.usertype==4) { %>
				第三方用户
				<%	} %>
				<% if(item.usertype==5) { %>
				API用户
				<%	} %>
				<% if(item.usertype==9) { %>
				其他用户
				<%	} %>
			</td>
			<td>${item.email}</td>
			<td>${item.tel}</td>
			<td>${item.create_time}</td>
			<td>
				<a href="javascript:void(0);" class="btn btn-sm btn-success" onclick="oper.view(${item.userid});">查看</a>
				<a href="javascript:void(0);" class="btn btn-sm btn-primary" onclick="oper.edit(${item.userid});">修改</a>
				<a href="javascript:void(0);" class="btn btn-sm btn-danger" onclick="oper.del(${item.userid});">删除</a>
				<a href="javascript:void(0);" class="btn btn-sm btn-primary" onclick="oper.auth(${item.userid});">授权</a>
			</td>
		</tr>
		<% } %>
		</tbody>
	</table>
	<%include("/pages/includes/paginator.html"){} %>
</form>
<%}; %>


<% layout("/pages/template/_layout.html",{head:headContent,body:bodyContent}){ %>
<%} %>